package com.chunuo.statistics.schedule;

import com.chunuo.statistics.service.DailyService;
import com.chunuo.statistics.utils.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * 类的作用
 *
 * @author liujiamiao
 * @email 2544296058@qq.com
 * @date 2020-07-31 17:54
 */
@Component
public class ScheduleTask {

    @Autowired
    private DailyService dailyService;

    //在每天凌晨0点，把前一天数据进行数据查询添加
    @Scheduled(cron = "0 0 0 * * ?")
    public void task2() {
        dailyService.registerCount(DateUtil.formatDate(DateUtil.addDays(new Date(), -1)));
    }

}
